﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BitPortal.Business;

namespace BitPortal.Admin.Article.Category.Module
{
    public partial class CategoryCombobox : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //BindData(null,"");
            }
        }
        public void BindData(BitPortal.Models.ArticleCategory parent, string prefix)
        {
            foreach (BitPortal.Models.ArticleCategory ac in ArticleCategoryBLL.GetChilds(parent))
            {
                cbCategory.Items.Add(new Ext.Net.ListItem(prefix + " " + ac.Name, ac.CategoryID.ToString()));
                BindData(ac, prefix + "----");
            }
        }
        public Ext.Net.ComboBox ComboboxCategory
        {
            get { return cbCategory; }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            cbCategory.Items.Clear();
            BindData(null, "");
            if (cbCategory.Items.Count > 0)
            {
                cbCategory.SelectedIndex = 0;
            }
        }
    }
}